/**
 * 
 */
package fb.test.uitl;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;


/**
 * @author hoannguyen
 *
 */
public final class JSONUtils {

	/**
	 * To convert from an object to a JSON string
	 * 
	 * @param object
	 * @return
	 */
	public static String convertObjectToJSON(Object object){
		
		String jsonString = "";
		
		ObjectMapper mapper = new ObjectMapper();
		try {
			jsonString = mapper.writeValueAsString(object);
		} catch (JsonGenerationException e) {
			LogUtils.log(e);
		} catch (JsonMappingException e) {
			LogUtils.log(e);
		} catch (IOException e) {
			LogUtils.log(e);
		}
				
		return jsonString;
	}
}
